tonal-freq ![npm version](https://img.shields.io/npm/v/tonal-freq.svg)
![tonal](https://img.shields.io/badge/tonal-freq-yellow.svg)
tonal-freq
is a collection of functions to perform calculations related to frequencies.
This is part of tonal music theory library.
You can install via npm: npm i --save tonal-freq
API Reference
- toEqualTemp(ref) ⇒
function
Return a function that converts midi or notes names to frequency using
equal temperament.
- toFreq(note) ⇒
Float
Get the frequency of a pitch using equal temperament scale and A4 equal to 440Hz
- fromEqualTemp(ref) ⇒
function
Create a function that returns a midi number from a frequency using an
equal temperament and ref
frequency as 'A4' frequency.
- midiFromFreq(freq) ⇒
Integer
Get note from frequency using a equal temeperament scale and 440Hz as
freq reference
- fromFreq(freq) ⇒
String
Get note name from frequency using an equal temperament scale with 440Hz
as reference
- cents(base, freq) ⇒
Float
Get difference in cents between two frequencies. The frequencies can be
expressed with hertzs or midi numbers or note names
toEqualTemp(ref) ⇒ function
Return a function that converts midi or notes names to frequency using
equal temperament.
Kind: global function
Returns: function
- the frequency calculator. It accepts midi numbers,
note names, pitches and returns a float.
Param | Type | Description |
---|
ref | Float | the tuning reference |
Example
import { toEqualTemp } from 'tonal-freq'
const toFreq = toEqualTemp(444)
toFreq('A3')
toFreq(note) ⇒ Float
Get the frequency of a pitch using equal temperament scale and A4 equal to 440Hz
Kind: global function
Returns: Float
- the frequency in herzs
Param | Type | Description |
---|
note | Number | String | the note name or midi number |
Example
import { toFreq } from 'tonal-freq'
toFreq('A4')
tonal.toFreq('C4')
fromEqualTemp(ref) ⇒ function
Create a function that returns a midi number from a frequency using an
equal temperament and ref
frequency as 'A4' frequency.
Kind: global function
Returns: function
- a function that converts from frequency to midi
Param | Type | Description |
---|
ref | Float | the frequency of A4 |
midiFromFreq(freq) ⇒ Integer
Get note from frequency using a equal temeperament scale and 440Hz as
freq reference
Kind: global function
Returns: Integer
- midi number
fromFreq(freq) ⇒ String
Get note name from frequency using an equal temperament scale with 440Hz
as reference
Kind: global function
Returns: String
- note name
cents(base, freq) ⇒ Float
Get difference in cents between two frequencies. The frequencies can be
expressed with hertzs or midi numbers or note names
Kind: global function
Returns: Float
- The difference in cents
Param | Type |
---|
base | Float | Integer | String |
freq | Float | Integer | String |
Example
import { cents } from 'tonal-freq'
cents('C4', 261)